package com.uinnova.product.eam.init.schedule;

import com.binary.framework.bean.annotation.Comment;
import com.uinnova.product.eam.init.schedule.job.OceanDataSyncJob;
import org.quartz.*;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Comment("ocean数据同步定时任务配置")
@Configuration
public class OceanDataSyncConfiguration {

//    @Value("${guotou.ocean.data.sync.cron:0 0/2 * * * ?}")
    @Value("${guotou.ocean.data.sync.cron:0 0 0/1 * * ?}")
    private String oceanDataSyncCron;

    @Bean
    public JobDetail oceanSyncJob() {
        return JobBuilder.newJob(OceanDataSyncJob.class).withIdentity("OceanDataSyncJob").storeDurably().build();
    }

    @Bean
    public Trigger oceanSyncJobTrigger(JobDetail oceanSyncJob) {
        CronScheduleBuilder scheduleBuilder = CronScheduleBuilder.cronSchedule(oceanDataSyncCron);
        return TriggerBuilder.newTrigger().forJob(oceanSyncJob)
                .withIdentity("OceanDataSyncJob").withSchedule(scheduleBuilder).build();
    }

}